Evaluation of COVID-19 Data Analysis Results

Author: Vishwas Narayan
In [1]:
#Import Statements
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pandas.plotting import radviz
import plotly.express as plotlybar
import plotly.express as px
import plotly.graph_objects as go
import warnings
warnings.filterwarnings('ignore')
sns.set_theme(style="darkgrid")
In [2]:
#Reading the datasets and storing it in a dataframe
us_counties_df=pd.read_csv('2021-04-21_us_counties_covid19_daily.csv')
us_states_df=pd.read_csv('2021-04-21_us_states_covid19_daily.csv')
us_daily_df=pd.read_csv('2021-04-21_covid19_daily.csv')
us_postal_code_df=pd.read_excel('US postal code.xlsx')
In [3]:
#Formatting the dataframe by including the 'State' column
us_states_df.rename(columns={'state':'Postal Code'},inplace=True)
us_states_df=us_states_df.merge(us_postal_code_df,on=['Postal Code'],how='left')
us_states_df.head()
Out[3]:
date Postal Code positive probableCases negative pending totalTestResultsSource totalTestResults hospitalizedCurrently hospitalizedCumulative ... deathIncrease hospitalizedIncrease hash commercialScore negativeRegularScore negativeScore positiveScore score grade State/District
0 20201206 AK 35720.0 NaN 1042056.0 NaN totalTestsViral 1077776.0 164.0 799.0 ... 0 0 7b1d31e2756687bb9259b29195f1db6cdb321ea6 0 0 0 0 0 NaN Alaska
1 20201206 AL 269877.0 45962.0 1421126.0 NaN totalTestsPeopleViral 1645041.0 1927.0 26331.0 ... 12 0 19454ed8fe28fc0a7948fc0771b2f3c846c1c92e 0 0 0 0 0 NaN Alabama
2 20201206 AR 170924.0 22753.0 1614979.0 NaN totalTestsViral 1763150.0 1076.0 9401.0 ... 40 21 25fc83bffff5b32ba1a737be8e087fad9f4fde33 0 0 0 0 0 NaN Arkansas
3 20201206 AS 0.0 NaN 2140.0 NaN totalTestsViral 2140.0 NaN NaN ... 0 0 8c39eec317586b0c34fc2903e6a3891ecb00469e 0 0 0 0 0 NaN American Samoa
4 20201206 AZ 364276.0 12590.0 2018813.0 NaN totalTestsPeopleViral 2370499.0 2977.0 28248.0 ... 25 242 7cf59da9e4bc31d905e179211313d08879880a85 0 0 0 0 0 NaN Arizona

5 rows × 56 columns

In [4]:
#Formatting the 'Date' Column to date-time format
us_states_df['date']=pd.to_datetime(us_states_df['date'],format='%Y%m%d')
us_daily_df['date']=pd.to_datetime(us_daily_df['date'],format='%Y%m%d')
us_states_df.rename(columns={'State/District':'State'},inplace=True)
In [5]:
us_daily_df.head()
Out[5]:
date states positive negative pending hospitalizedCurrently hospitalizedCumulative inIcuCurrently inIcuCumulative onVentilatorCurrently ... totalTestResults lastModified total posNeg deathIncrease hospitalizedIncrease negativeIncrease positiveIncrease totalTestResultsIncrease hash
0 2020-12-06 56 14534035 161986294 13592.0 101487.0 585676.0 20145.0 31946.0 7094.0 ... 204063869 2020-12-06T24:00:00Z 0 0 1138 2256 1172590 176771 1634532 9cf16504f91958e803a2197daf8c2528a4eddc18
1 2020-12-05 56 14357264 160813704 13433.0 101190.0 583420.0 19950.0 31831.0 7005.0 ... 202429337 2020-12-05T24:00:00Z 0 0 2445 3316 1526995 211073 2169756 6249216c5f097c94ce33a811dab011a483a42404
2 2020-12-04 56 14146191 159286709 12714.0 101276.0 580104.0 19858.0 31608.0 6999.0 ... 200259581 2020-12-04T24:00:00Z 0 0 2563 4652 1260657 224831 1854869 ae30ea088584335ba4d57ee927f8dbda6add74db
3 2020-12-03 56 13921360 158026052 15106.0 100755.0 575452.0 19723.0 31276.0 6867.0 ... 198404712 2020-12-03T24:00:00Z 0 0 2706 5331 1238465 210204 1828230 0f253d185ecb336cdd18a4c61996eda1b7eef13b
4 2020-12-02 56 13711156 156787587 14368.0 100322.0 570121.0 19680.0 31038.0 6855.0 ... 196576482 2020-12-02T24:00:00Z 0 0 2733 5028 982032 195796 1459202 477c17b6302d0485195e77ecf8270a974f7a3c82

5 rows × 25 columns

In [6]:
us_states_df.head()
Out[6]:
date Postal Code positive probableCases negative pending totalTestResultsSource totalTestResults hospitalizedCurrently hospitalizedCumulative ... deathIncrease hospitalizedIncrease hash commercialScore negativeRegularScore negativeScore positiveScore score grade State
0 2020-12-06 AK 35720.0 NaN 1042056.0 NaN totalTestsViral 1077776.0 164.0 799.0 ... 0 0 7b1d31e2756687bb9259b29195f1db6cdb321ea6 0 0 0 0 0 NaN Alaska
1 2020-12-06 AL 269877.0 45962.0 1421126.0 NaN totalTestsPeopleViral 1645041.0 1927.0 26331.0 ... 12 0 19454ed8fe28fc0a7948fc0771b2f3c846c1c92e 0 0 0 0 0 NaN Alabama
2 2020-12-06 AR 170924.0 22753.0 1614979.0 NaN totalTestsViral 1763150.0 1076.0 9401.0 ... 40 21 25fc83bffff5b32ba1a737be8e087fad9f4fde33 0 0 0 0 0 NaN Arkansas
3 2020-12-06 AS 0.0 NaN 2140.0 NaN totalTestsViral 2140.0 NaN NaN ... 0 0 8c39eec317586b0c34fc2903e6a3891ecb00469e 0 0 0 0 0 NaN American Samoa
4 2020-12-06 AZ 364276.0 12590.0 2018813.0 NaN totalTestsPeopleViral 2370499.0 2977.0 28248.0 ... 25 242 7cf59da9e4bc31d905e179211313d08879880a85 0 0 0 0 0 NaN Arizona

5 rows × 56 columns

In [7]:
cases_CA = us_states_df[us_states_df['State'] == 'California']
cases_CA
Out[7]:
date Postal Code positive probableCases negative pending totalTestResultsSource totalTestResults hospitalizedCurrently hospitalizedCumulative ... deathIncrease hospitalizedIncrease hash commercialScore negativeRegularScore negativeScore positiveScore score grade State
5 2020-12-06 CA 1341700.0 NaN 23853346.0 NaN totalTestsViral 25195046.0 10624.0 NaN ... 85 0 2fbb11905a59ffc894c8ec1ec6f051691be2381c 0 0 0 0 0 NaN California
61 2020-12-05 CA 1311625.0 NaN 23590350.0 NaN totalTestsViral 24901975.0 10273.0 NaN ... 209 0 86d01cdbc69e8f31a43025a1f3f05d3468d5ec15 0 0 0 0 0 NaN California
117 2020-12-04 CA 1286557.0 NaN 23388921.0 NaN totalTestsViral 24675478.0 9948.0 NaN ... 145 0 aafc314108ebfaf9c877640c12061ff460989a35 0 0 0 0 0 NaN California
173 2020-12-03 CA 1264539.0 NaN 23210103.0 NaN totalTestsViral 24474642.0 9702.0 NaN ... 113 0 960e056249878f14b2efda03317df7c3bab66d06 0 0 0 0 0 NaN California
229 2020-12-02 CA 1245948.0 NaN 23053178.0 NaN totalTestsViral 24299126.0 9365.0 NaN ... 113 0 a7a45a38ce8e8f1f4aa133438262997831fa0fc0 0 0 0 0 0 NaN California
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
15257 2020-03-08 CA 88.0 NaN 462.0 NaN totalTestsViral 550.0 NaN NaN ... 0 0 f4b563adfd7eb6ca42789ae99d3b0f7bad4e2913 0 0 0 0 0 NaN California
15308 2020-03-07 CA 69.0 NaN 462.0 NaN totalTestsViral 531.0 NaN NaN ... 0 0 460b13c43b9f5ac14cef25a0a4143e666e84e9fc 0 0 0 0 0 NaN California
15358 2020-03-06 CA 60.0 NaN 462.0 NaN totalTestsViral 522.0 NaN NaN ... 0 0 5dcb4e2356df148513671071860ec5a059dc6de1 0 0 0 0 0 NaN California
15395 2020-03-05 CA 53.0 NaN 462.0 NaN totalTestsViral 515.0 NaN NaN ... 0 0 d3243f8be7b1c96e093dbeab8d271ff7ffe58a8a 0 0 0 0 0 NaN California
15425 2020-03-04 CA 53.0 NaN 462.0 NaN totalTestsViral 515.0 NaN NaN ... 0 0 aa361b70e8d21881b07d9cd5a11d86c377920af2 0 0 0 0 0 NaN California

278 rows × 56 columns

In [8]:
#Grouping the US States and resetting their indexes 
us_states_grp = us_states_df.groupby('State').sum().reset_index()
us_states_grp
Out[8]:
State positive probableCases negative pending totalTestResults hospitalizedCurrently hospitalizedCumulative inIcuCurrently inIcuCumulative ... totalTestResultsIncrease posNeg deathIncrease hospitalizedIncrease commercialScore negativeRegularScore negativeScore positiveScore score grade
0 Alabama 24282758.0 2594667.0 1.595672e+08 132.0 1.812461e+08 225784.0 2622751.0 0.0 298888.0 ... 1645041 183849960 3889 26331 0 0 0 0 0 0.0
1 Alaska 1656760.0 0.0 7.703370e+07 68.0 7.869046e+07 11272.0 55545.0 0.0 0.0 ... 1077768 78690463 143 799 0 0 0 0 0 0.0
2 American Samoa 0.0 0.0 2.497910e+05 315.0 2.497910e+05 0.0 0.0 0.0 0.0 ... 2140 249791 0 0 0 0 0 0 0 0.0
3 Arizona 35894317.0 621231.0 2.019179e+08 1106.0 2.372078e+08 329987.0 3215012.0 95701.0 0.0 ... 2370470 237812241 6950 28244 0 0 0 0 0 0.0
4 Arkansas 13422076.0 772286.0 1.471049e+08 809.0 1.597583e+08 101998.0 861542.0 23172.0 344.0 ... 1763144 160526941 2660 9401 0 0 0 0 0 0.0
5 California 126643296.0 0.0 2.183820e+09 815100.0 2.310461e+09 1280754.0 0.0 350037.0 0.0 ... 25194531 2310463128 19876 0 0 0 0 0 0 0.0
6 Colorado 15736738.0 991474.0 1.429302e+08 121.0 2.421971e+08 152873.0 1616107.0 0.0 0.0 ... 3478160 158666976 2724 14868 0 0 0 0 0 0.0
7 Connecticut 13164724.0 563856.0 2.596130e+08 8.0 2.727777e+08 129149.0 2460004.0 0.0 0.0 ... 3422098 272777728 5146 12257 0 0 0 0 0 0.0
8 Delaware 3914371.0 193781.0 4.332321e+07 128.0 7.141170e+07 31160.0 0.0 2869.0 0.0 ... 778298 47237577 793 0 0 0 0 0 0 0.0
9 District of Columbia 2988585.0 0.0 5.891800e+07 90.0 6.188026e+07 37846.0 0.0 9983.0 0.0 ... 734627 61906584 697 0 0 0 0 0 0 0.0
10 Florida 106829756.0 3547693.0 7.511425e+08 743725.0 1.253924e+09 640342.0 7070416.0 0.0 0.0 ... 13083520 857972227 19423 57185 0 0 0 0 0 0.0
11 Georgia 48555886.0 0.0 4.069541e+08 0.0 4.550237e+08 421679.0 4667944.0 0.0 873330.0 ... 4476052 455509959 9806 36039 0 0 0 0 0 0.0
12 Guam 436761.0 5360.0 7.439971e+06 0.0 7.876732e+06 6443.0 0.0 1463.0 0.0 ... 86549 7876732 113 0 0 0 0 0 0 0.0
13 Hawaii 1622759.0 18612.0 3.877184e+07 0.0 6.091493e+07 17750.0 114706.0 4008.0 0.0 ... 701774 40394602 262 1325 0 0 0 0 0 0.0
14 Idaho 7240845.0 812680.0 4.303110e+07 0.0 4.945923e+07 38756.0 308361.0 8983.0 73672.0 ... 490360 50271941 1032 4372 0 0 0 0 0 0.0
15 Illinois 59718277.0 502566.0 8.621404e+08 792.0 9.218587e+08 691693.0 0.0 165192.0 0.0 ... 11101086 921858727 14116 0 0 0 0 0 0 0.0
16 Indiana 24131741.0 0.0 1.979854e+08 0.0 3.536123e+08 292804.0 2464625.0 105044.0 489413.0 ... 4577210 222117167 6242 28367 0 0 0 0 0 0.0
17 Iowa 15592895.0 0.0 1.070533e+08 105.0 1.226462e+08 104211.0 1696.0 26762.0 0.0 ... 1098574 122646170 2683 0 0 0 0 0 0 0.0
18 Kansas 10689787.0 0.0 7.309409e+07 23.0 8.378387e+07 61105.0 516346.0 17016.0 143071.0 ... 845182 83783873 1786 5417 0 0 0 0 0 0.0
19 Kentucky 12395410.0 1629744.0 2.047191e+08 3.0 2.154497e+08 158169.0 1042749.0 40871.0 311287.0 ... 2731998 217114516 2072 10678 0 0 0 0 0 0.0
20 Louisiana 28037617.0 448982.0 3.383971e+08 0.0 3.664347e+08 263304.0 0.0 0.0 0.0 ... 3608083 366434674 6584 0 0 0 0 0 0 0.0
21 Maine 1084543.0 112238.0 6.785972e+07 81.0 6.894426e+07 7524.0 93823.0 2989.0 0.0 ... 914179 68944262 227 768 0 0 0 0 0 0.0
22 Maryland 22839105.0 0.0 2.330740e+08 26.0 4.074861e+08 175843.0 3016959.0 54692.0 0.0 ... 4685476 255913080 4846 22095 0 0 0 0 0 0.0
23 Massachusetts 29496462.0 698204.0 3.368118e+08 0.0 6.772539e+08 291703.0 2693788.0 62011.0 0.0 ... 8970251 366308239 11004 14397 0 0 0 0 0 0.0
24 Michigan 30480853.0 2643377.0 5.692912e+08 215.0 5.997721e+08 345629.0 0.0 104903.0 0.0 ... 6965044 599772070 10321 0 0 0 0 0 0 0.0
25 Minnesota 20217017.0 146430.0 2.252251e+08 0.0 3.404660e+08 128205.0 1502854.0 42528.0 409242.0 ... 4431640 245442081 3984 18233 0 0 0 0 0 0.0
26 Mississippi 15712257.0 1480623.0 1.061303e+08 0.0 1.218426e+08 181653.0 1037345.0 45323.0 0.0 ... 1147326 121842562 3961 7486 0 0 0 0 0 0.0
27 Missouri 21132851.0 0.0 1.751843e+08 0.0 2.863743e+08 274210.0 0.0 26348.0 0.0 ... 3196162 196317108 4192 0 0 0 0 0 0 0.0
28 Montana 3100050.0 0.0 5.356992e+07 57.0 5.666997e+07 34877.0 144058.0 1217.0 0.0 ... 688203 56669972 736 2836 0 0 0 0 0 0.0
29 Nebraska 9117558.0 0.0 6.731510e+07 270.0 1.125054e+08 60014.0 414904.0 162.0 0.0 ... 1456367 76432653 1194 4547 0 0 0 0 0 0.0
30 Nevada 13245373.0 0.0 1.006216e+08 164.0 1.676421e+08 155112.0 0.0 39789.0 0.0 ... 1733231 113867004 2315 0 0 0 0 0 0 0.0
31 New Hampshire 1836236.0 0.0 4.368606e+07 43958.0 7.448044e+07 12461.0 147799.0 0.0 44077.0 ... 861467 45522291 564 849 0 0 0 0 0 0.0
32 New Jersey 46389594.0 0.0 5.590741e+08 7792.0 6.054636e+08 532013.0 4981616.0 122424.0 0.0 ... 6286813 605463645 17321 42456 0 0 0 0 0 0.0
33 New Mexico 6396778.0 0.0 1.499408e+08 0.0 1.563375e+08 54179.0 683296.0 0.0 0.0 ... 1647960 156337540 1749 7321 0 0 0 0 0 0.0
34 New York 104056991.0 0.0 1.725435e+09 520.0 1.829492e+09 963633.0 21377064.0 266218.0 0.0 ... 20594694 1829492443 27149 89995 0 0 0 0 0 0.0
35 North Carolina 34455710.0 885881.0 4.610905e+08 302.0 4.955462e+08 237214.0 0.0 45032.0 0.0 ... 5611275 495546200 5543 0 0 0 0 0 0 0.0
36 North Dakota 4447121.0 0.0 3.664738e+07 52.0 9.966663e+07 26934.0 175734.0 3497.0 29097.0 ... 1132025 41094505 1019 2880 0 0 0 0 0 0.0
37 Northern Mariana Islands 12579.0 0.0 2.552027e+06 139.0 2.564606e+06 0.0 604.0 0.0 0.0 ... 17116 2564606 2 4 0 0 0 0 0 0.0
38 Ohio 29704003.0 1645295.0 4.849908e+08 1139.0 5.146948e+08 288591.0 2910090.0 84376.0 631074.0 ... 6475703 514694825 6959 29233 0 0 0 0 0 0.0
39 Oklahoma 14132507.0 0.0 1.792977e+08 696899.0 1.934302e+08 143591.0 1070546.0 52514.0 0.0 ... 2225314 193430227 1896 13119 0 0 0 0 0 0.0
40 Oregon 5823042.0 275393.0 1.122620e+08 2964.0 1.180851e+08 55459.0 461707.0 13993.0 0.0 ... 2090081 118085061 1033 4859 0 0 0 0 0 0.0
41 Pennsylvania 32597219.0 1327374.0 3.071087e+08 598.0 3.397060e+08 338837.0 7233.0 23043.0 0.0 ... 3349148 339705961 11331 0 0 0 0 0 0 0.0
42 Puerto Rico 3631722.0 32260.0 5.095816e+07 47728.0 5.458988e+07 73767.0 0.0 10581.0 0.0 ... 362629 54589878 1192 0 0 0 0 0 0 0.0
43 Rhode Island 5464042.0 0.0 5.433059e+07 2757.0 1.330656e+08 40217.0 567231.0 6735.0 0.0 ... 1608848 59794636 1413 4843 0 0 0 0 0 0.0
44 South Carolina 22572079.0 746812.0 1.928926e+08 0.0 2.154647e+08 183702.0 1427475.0 30664.0 0.0 ... 2528186 215464681 4566 12380 0 0 0 0 0 0.0
45 South Dakota 4878909.0 171470.0 2.821025e+07 2576.0 3.308918e+07 42424.0 318875.0 2616.0 0.0 ... 339990 33089161 1110 4835 0 0 0 0 0 0.0
46 Tennessee 32128971.0 1464674.0 4.214871e+08 0.0 4.536161e+08 272357.0 1361363.0 46886.0 0.0 ... 4690521 453616068 4943 12593 0 0 0 0 0 0.0
47 Texas 114486497.0 0.0 9.101918e+08 0.0 1.024678e+09 1198295.0 0.0 256998.0 0.0 ... 11360975 1024678340 22594 0 0 0 0 0 0 0.0
48 Utah 13802913.0 0.0 1.292164e+08 0.0 1.823823e+08 56289.0 705014.0 17347.0 157555.0 ... 1922220 143019333 939 8822 0 0 0 0 0 0.0
49 Vermont 406638.0 3047.0 2.534639e+07 0.0 4.611163e+07 3904.0 473.0 115.0 0.0 ... 583802 25753030 79 0 0 0 0 0 0 0.0
50 Virgin Islands 168555.0 0.0 2.743601e+06 9040.0 2.912156e+06 9.0 0.0 0.0 0.0 ... 29292 2912156 23 0 0 0 0 0 0 0.0
51 Virginia 25253511.0 1610415.0 3.029962e+08 90951.0 3.294802e+08 288669.0 1976043.0 68996.0 0.0 ... 3485756 328249694 4200 15295 0 0 0 0 0 0.0
52 Washington 15856729.0 0.0 2.990264e+08 126.0 3.146730e+08 123370.0 1308170.0 16806.0 0.0 ... 3133845 314883163 2925 11475 0 0 0 0 0 0.0
53 West Virginia 2908712.0 220692.0 9.306718e+07 148.0 9.597589e+07 36113.0 506.0 11854.0 219.0 ... 1223362 95975887 838 0 0 0 0 0 0 0.0
54 Wisconsin 25920979.0 1567794.0 2.348044e+08 42711.0 3.912186e+08 163285.0 1492536.0 43615.0 233038.0 ... 4623220 260725355 3952 18216 0 0 0 0 0 0.0
55 Wyoming 1563677.0 232689.0 1.523471e+07 0.0 3.176866e+07 11267.0 57743.0 0.0 0.0 ... 417626 16798384 257 852 0 0 0 0 0 0.0

56 rows × 47 columns

In [9]:
#Horizontal Barplot showing the Top 10 States affected by COVID-19
top_10 = us_states_grp.sort_values(by=['total'],ascending=False).head(10)
plt.figure(figsize=(15,6))
x=top_10['total']
y=top_10['State']
plot = sns.barplot(x,y)
for i,(value,name) in enumerate(zip(x,y)):
    plot.text(value,i-0.05,f'{value:,.0f}',size=10)
plt.show()
In [10]:
# Comparison of Positive versus Negative Cases for the Top 5 States affected due to COVID-19
top_5 = us_states_grp.sort_values(by=['total'], ascending=False).head()

### Generate a Barplot
plt.figure(figsize=(15,5))
negative = sns.barplot(top_5['negative'], top_5['State'], color = 'blue', label='negative')
positive = sns.barplot(top_5['positive'], top_5['State'], color = 'cyan', label='positive')
### Add Texts for Barplots
for i,(value,name) in enumerate(zip(top_5['negative'],top_5['State'])):
    negative.text(value,i-0.05,f'{value:,.0f}',size=10)
for i,(value,name) in enumerate(zip(top_5['positive'],top_5['State'])):
    positive.text(value,i-0.05,f'{value:,.0f}',size=10)
plt.legend(loc=4)
plt.show()
In [11]:
#Horizontal Barplot showing the Top 10 States with highest hospitalization by COVID-19 
top_10 = us_states_grp.sort_values(by=['hospitalizedCumulative'],ascending=False).head(10)
plt.figure(figsize=(15,6))
x=top_10['hospitalizedCumulative']
y=top_10['State']
plot = sns.barplot(x,y)
for i,(value,name) in enumerate(zip(x,y)):
    plot.text(value,i-0.05,f'{value:,.0f}',size=10)
plt.show()
In [12]:
# Comparison of Hospitalized versus Deaths Cases for the Top 5 States affected by COVID-19
top_5 = us_states_grp.sort_values(by=['hospitalizedCumulative'], ascending=False).head()

### Generate a Barplot
plt.figure(figsize=(15,5))
hospitalized = sns.barplot(top_5['hospitalized'], top_5['State'], color = 'green', label='hospitalized')
death = sns.barplot(top_5['death'], top_5['State'], color = 'red', label='death')
### Add Texts for Barplots
for i,(value,name) in enumerate(zip(top_5['hospitalized'],top_5['State'])):
    hospitalized.text(value,i-0.05,f'{value:,.0f}',size=10)
for i,(value,name) in enumerate(zip(top_5['death'],top_5['State'])):
    death.text(value,i-0.05,f'{value:,.0f}',size=10)
plt.legend(loc=4)
plt.show()
In [13]:
#Dataframe for plotting the Choropleth for the United States COVID-19
us_states_map = us_states_df.groupby(['State','Postal Code'])[['positive','total','death','recovered','hospitalized','hospitalizedCurrently','onVentilatorCurrently','deathIncrease']].max().reset_index()
us_states_map.describe()
Out[13]:
positive total death recovered hospitalized hospitalizedCurrently onVentilatorCurrently deathIncrease
count 5.600000e+01 5.600000e+01 56.000000 4.800000e+01 42.000000 54.000000 36.000000 56.000000
mean 2.595363e+05 3.152391e+06 4881.678571 1.171759e+05 14018.404762 2575.925926 379.388889 133.642857
std 2.886487e+05 4.609699e+06 6182.213243 1.710476e+05 17488.556982 3439.192785 517.787948 180.247146
min 0.000000e+00 2.140000e+03 0.000000 2.900000e+01 4.000000 3.000000 0.000000 0.000000
25% 6.077050e+04 6.524252e+05 913.750000 1.344525e+04 2847.000000 531.250000 65.000000 30.000000
50% 1.882125e+05 1.826214e+06 2671.500000 4.884650e+04 9111.500000 1717.000000 205.500000 71.000000
75% 3.652110e+05 3.443466e+06 5717.750000 1.687425e+05 17485.750000 2828.250000 408.750000 158.000000
max 1.341700e+06 2.519505e+07 27149.000000 1.030716e+06 89995.000000 18825.000000 2425.000000 951.000000
In [14]:
#'Positive COVID-19 Cases in US'

figure = px.choropleth(us_states_map,
                       locations='Postal Code', 
                       locationmode='USA-states',
                       scope='usa',
                       color='positive', 
                       hover_name='State', 
                       color_continuous_scale='turbo', 
                       range_color=[1,1200000],
                       title='Positive COVID-19 Cases in US')
figure.show()
In [15]:
# 'Currently Hospitalized COVID-19 Cases in US'

figure = px.choropleth(us_states_map,
                       locations='Postal Code', 
                       locationmode='USA-states',
                       scope='usa',
                       color='hospitalizedCurrently', 
                       hover_name='State', 
                       color_continuous_scale='darkmint', 
                       range_color=[1,15000],
                       title='Currently Hospitalized COVID-19 Cases in US')
figure.show()
In [16]:
# 'COVID-19 Deaths in US'

figure = px.choropleth(us_states_map,
                       locations='Postal Code', 
                       locationmode='USA-states',
                       scope='usa',
                       color='death', 
                       hover_name='State', 
                       color_continuous_scale='portland', 
                       range_color=[1,20000],
                       title='COVID-19 Deaths in US')
figure.show()
In [17]:
# 'Increase in the COVID-19 Death Rate in the US'
figure = px.choropleth(us_states_map,
                       locations='Postal Code', 
                       locationmode='USA-states',
                       scope='usa',
                       color='deathIncrease', 
                       hover_name='State', 
                       color_continuous_scale='reds', 
                       range_color=[1,250],
                       title='Increase in the COVID-19 Death Rate in the US')
figure.show()
In [18]:
# 'COVID-19 Patients Currently on Ventilator in the US'

figure = px.choropleth(us_states_map,
                       locations='Postal Code', 
                       locationmode='USA-states',
                       scope='usa',
                       color='onVentilatorCurrently', 
                       hover_name='State', 
                       color_continuous_scale='teal', 
                       range_color=[1,300],
                       title='COVID-19 Patients Currently on Ventilator in the US')
figure.show()
In [19]:
# Grouping the States which are under LOCKDOWN
state_grp1 = us_states_df[us_states_df['Postal Code'].isin(['DC', 'IL', 'MD', 'MS','VA'])]
state_grp2 = us_states_df[us_states_df['Postal Code'].isin(['AZ', 'FL', 'NC', 'TX'])]
state_grp3 = us_states_df[us_states_df['Postal Code'].isin(['MO', 'LA', 'MA','IL','NY','MI','PA'])]
In [20]:
# Building a Pivot Table to Index 'States' for plotting 
grp1_pt = state_grp1.pivot_table(index=['State','date'],values=['positiveIncrease'],aggfunc=np.sum).reset_index()
grp2_pt = state_grp2.pivot_table(index=['State','date'],values=['recovered'],aggfunc=np.sum).reset_index()
grp2a_pt = state_grp2.pivot_table(index=['State','date'],values=['deathIncrease'],aggfunc=np.sum).reset_index()
grp3a_pt = state_grp3.pivot_table(index=['State','date'],values=['recovered'],aggfunc=np.sum).reset_index()
grp3b_pt = state_grp3.pivot_table(index=['State','date'],values=['death'],aggfunc=np.sum).reset_index()
In [21]:
# Plotting using Seaborn to Visualize the groups with thier attributes
sns.set_theme(style="darkgrid")
sns.relplot(x="date", y="positiveIncrease", hue='State', style='State', kind="line", height=6,aspect=2, data=grp1_pt).fig.autofmt_xdate()
sns.relplot(x="date", y="recovered", hue='State', kind="line", style='State', height=4,aspect=3, data=grp2_pt).fig.autofmt_xdate()
sns.relplot(x="date", y="deathIncrease", hue='State', kind="line", style='State', height=4,aspect=3, data=grp2a_pt).fig.autofmt_xdate()
sns.relplot(x="date", y="recovered", hue='State', kind="line", style='State', height=6,aspect=1, data=grp3a_pt).fig.autofmt_xdate()
sns.relplot(x="date", y="death", hue='State', kind="line", style='State', height=6,aspect=1, data=grp3b_pt).fig.autofmt_xdate()